// 爆炸图
function Bomb(obj) {
    this.init = function() {
        this.imgArr = [Tool.getImage('images/b1.gif'), Tool.getImage('images/b2.gif'), Tool.getImage('images/b3.gif'), Tool.getImage('images/b4.gif'), Tool.getImage('images/b1.gif'), Tool.getImage('images/b5.gif'), Tool.getImage('images/b6.gif'), Tool.getImage('images/b7.gif'), Tool.getImage('images/b8.gif'), Tool.getImage('images/b9.gif'), Tool.getImage('images/b10.gif')];

        // 爆炸的宽高
        this.width = 96;
        this.height = 96;

        // 爆炸图在canvas上的坐标
        this.x = obj.x + (obj.width - this.width) / 2;
        this.y = obj.y + (obj.height - this.height) / 2;

        // 默认爆炸图展示
        this.isShow = true;

        // 
        this.index = 0;

        // 最后生成时间
        this.lasttime = new Date().getTime();
    };
    this.init();

    this.draw = function() {
        if (this.isShow) {
            // 绘制
            ctx.drawImage(this.imgArr[this.index], this.x, this.y);

            this.index++;
            if (this.index == this.imgArr.length) {
                this.isShow = false;
            }
        }
    };
}

// 爆炸图生成
function BombSet() {
    this.init = function() {
        this.set = [];
    };
    this.init();

    this.draw = function() {
        // 循环子弹进行绘制
        for (var i = 0; i < this.set.length; i++) {
            // 子弹展示，则绘制
            if (this.set[i].isShow) {
                this.set[i].draw();
            } else {
                // 子弹已经出界，删除该元素
                this.set.splice(i, 1);
            }
        }
    }
}